package com.lxyk.yygh.hosp.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import com.lxyk.yygh.common.result.Result;
import com.lxyk.yygh.hosp.service.HospitalService;
import com.lxyk.yygh.model.hosp.Hospital;
import com.lxyk.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags="后台医院管理接口" )
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * 医院分页查询
     * @param page
     * @param limit
     * @param hospitalQueryVo
     * @return
     */
    @PostMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page, @PathVariable Integer limit, @RequestBody(required = false)HospitalQueryVo hospitalQueryVo){
       Page<Hospital> pageModel= hospitalService.listHosp(page,limit,hospitalQueryVo);
       return Result.ok(pageModel);
    }

    /**
     * 更新医院状态
     * @param id
     * @param status
     * @return
     */
    @ApiOperation(value = "更新医院上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result lock(@PathVariable("id") String id, @PathVariable("status") Integer status){
        hospitalService.updateStatus(id, status);
        return Result.ok();
    }

    /**
     * 获取医院详情
     * @param id
     * @return
     */
    @ApiOperation(value = "获取医院详情")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable String id) {
        return Result.ok(hospitalService.getHospById(id));
    }
}
